package designpattern.factory.factorymethod;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class OrderPizza {
    private PizzaFactory pizzaFactory;

    //订购pizza
    public void order(){
        do {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            try {
                String orderType = br.readLine();
                if(!orderType.equals("bj cheese") && !orderType.equals("bj greek")
                    && !orderType.equals("ld cheese") && !orderType.equals("ld greek")){
                    br.close();
                    return;
                }
                if(orderType.contains("bj")){
                    pizzaFactory = new BJPizzaFactory();
                }else if(orderType.contains("ld")){
                    pizzaFactory = new LDPizzaFactory();
                }
                pizzaFactory.createPizza(orderType);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }while (true);
    }
}
